#include<iostream.h>

int main(){
	int a,answer;
	cin>>a;
	for(int i=0;i<a;i++){
		int num[4];
		for(int j=0;j<4;j++)
			cin>>num[j];
		if(num[3]-num[2]==num[2]-num[1]&&num[2]-num[1]==num[1]-num[0])
			answer=2*num[3]-num[2];
		else answer=num[3]*num[3]/num[2];
		cout<<num[0]<<" "<<num[1]<<" "<<num[2]<<" "<<num[3]<<" "<<answer<<endl;
	}
	return 0;
}
